package com.invengo.module_check.ui.fragment.revoke;

import static com.invengo.module_check.data.entity.BundleKey.KEY_OP_STATE;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.navigation.fragment.NavHostFragment;

import com.invengo.module_check.BR;
import com.invengo.module_check.R;
import com.invengo.module_check.data.api.BusinessApi;
import com.invengo.module_check.data.entity.ActionArgs;
import com.invengo.module_check.data.entity.BundleKey;
import com.invengo.module_check.data.repsitory.business.source.BusinessSource;
import com.invengo.module_check.databinding.FragmentRevokeBinding;

import java.io.Serializable;

import me.goldze.mvvmhabit.base.BaseFragment;

public class RevokeFragment extends BaseFragment<FragmentRevokeBinding, RevokeViewModel> {
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_revoke;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initViewObservable() {
        viewModel.ui.nextEvent.observe(this, bookBeans -> {
            Bundle bundle = new Bundle();
            bundle.putSerializable(BundleKey.KEY_BOOKS, (Serializable) bookBeans);
            bundle.putSerializable(BundleKey.KEY_ACTION, ActionArgs.ACTION_REVOKE);
            bundle.putBoolean(KEY_OP_STATE, bookBeans != null);
            bundle.putString(BundleKey.KEY_TITLE, "撤销强制定位");
            NavHostFragment.findNavController(this).navigate(ActionArgs.ACTION_REVOKE.getResultAction(), bundle);
        });
    }
}
